

init();

function init() {
    //1.查询进度列表
    queryScheduleList();
}


/**
 * 详情
 */
function queryScheduleDetail(id) {
    $.ajax({
        url :   "schedule/getschedule",
        type:   "post",
        data:JSON.stringify({
            recordId : id
        }),
        contentType:"application/json;",
        success:function(data){
            goToLogin(data);
            console.log(data);
            var scheduleDetail = data.data;
            $("#projectName").val(scheduleDetail.projectName);
            $("#scheduleName").val(scheduleDetail.scheduleName);
            $("#preparationStage").val(scheduleDetail.preparationStage + "%");
            $("#baseStage").val(scheduleDetail.baseStage + "%");
            $("#subjectStage").val(scheduleDetail.subjectStage + "%");
            $("#decorateStage").val(scheduleDetail.decorateStage + "%");
            $("#greenStage").val(scheduleDetail.greenStage + "%");
            $("#allStage").val(scheduleDetail.allPercent + "%");
            $("#oprUserName").val(scheduleDetail.oprUserName);
            $("#oprDate").val(new Date(scheduleDetail.oprDate).toLocaleDateString());
        }
    });
}

/**
 * 列表
 */
function queryScheduleList(pageIndex) {
    var name = "";
    name = $("#name").val();
    if(pageIndex == null){
        pageIndex = 0;
    }
    $.ajax({
        url :   prefixUrl + "schedule/getallscheduleinfo",
        type:   "post",
        data:JSON.stringify({
            projectName : name,
            pageIndex : pageIndex,
            auditState : 9
        }),
        contentType:"application/json;",
        success:function(data){
            goToLogin(data);
            var list = data.data.rows;
            var scheduleHtml  = '<thead>'
                +'<tr>'
                +'<th>序号</th>'
                +'<th>项目名称</th>'
                +'<th>提交人</th>'
                +'<th>提交时间	</th>'
                +'<th>项目总进度百分比</th>'
                +'<th>操作</th>'
                +'</tr>'
                +'</thead>'
                +'<tbody>';
            for(var i=0; i<list.length; i++){
                scheduleHtml = scheduleHtml
                    +'<tr>'
                    +'<td>' + (parseInt(i) + 1) + '</td>'
                    +'<td>'
                    +list[i].projectName
                    +'</td>'
                    +'<td>'
                    +list[i].oprUserName
                    +'</td>'
                    +'<td>'
                    +new Date(list[i].oprDate).toLocaleDateString()
                    +'</td>'
                    +'<td>'
                    +list[i].allPercent + "%"
                    +'</td>'
                    +'<td>'
                    +'<button type="button" class="btn btn-info mar-r-5" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo" onclick=queryScheduleDetail("'
                    + list[i].recordId
                    +'")><i class="glyphicon glyphicon-search"></i></button>'
                    +'</td>'
                    +'</tr>';
            }
            scheduleHtml = scheduleHtml + +'</tbody>';
            $("#scheduleList").html(scheduleHtml);
            getNumberList(data);
        }
    });
}
